/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ar.edu.unicen.twitter.suggest.frontend.controllers;

import ar.edu.unicen.twitter.suggest.backend.datasources.TwitterFacade;
import ar.edu.unicen.twitter.suggest.backend.dtos.UsuarioProxy;
import ar.edu.unicen.twitter.suggest.commons.dtos.Usuario;
import ar.edu.unicen.twitter.suggest.interfaces.exceptions.RejectedException;
import ar.edu.unicen.twitter.suggest.interfaces.exceptions.TwitterException;
import ar.edu.unicen.twitter.suggest.interfaces.exceptions.UserNotFoundException;
import ar.edu.unicen.twitter.suggest.interfaces.exceptions.UserProtectedException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.primefaces.json.JSONArray;
import org.primefaces.json.JSONException;
import org.primefaces.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 *
 * @author Alex
 */
@Controller("sessionController")
public class SessionController {

    @Autowired
    TwitterFacade twitterFacade;
    
    private String userName = "jasigno";
    private Usuario user;
    
    public SessionController() {
    }
    
    public void login(){
        try {
            user = twitterFacade.getUser(userName);
        } catch (UserNotFoundException ex) {
            Logger.getLogger(SessionController.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UserProtectedException ex) {
            Logger.getLogger(SessionController.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RejectedException ex) {
            Logger.getLogger(SessionController.class.getName()).log(Level.SEVERE, null, ex);
        } catch (TwitterException ex) {
            Logger.getLogger(SessionController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    public void logout(){
        
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
    public Usuario getUser(){
        return user;
    } 
}
